//% extends SigSlot

function Element( tag )
{
    this.Super();
    
    if( typeof(tag) == "string" )
    {
        tag = document.createElement(tag);
        tag.id = "instance" + this.getId();
    }
    (function(c){
        var className = "Final" + c + " " + tag.className + " ";

        while( c != "Element" )
        {
            className += c + " ";
            var data = oboe.loadedClasses[ c ];
            if( !data ) break;
            c = data.superClass;
        }

        tag.className = className;
    })( this.constructor.name );
    
    this.getElement = function(){ return tag; };
    
    this.addChild = function( c )
    {
        this.SigSlot.addChild( c );
        if( c instanceof Element )
        {
            tag.appendChild( c.getElement() );
        }
    };
    
    this.removeChild = function( c )
    {
        this.SigSlot.removeChild( c );
        if( c instanceof Element )
        {
            tag.removeChild( c.getElement() );
        }
    };
}